package cn.edu.wynu.d9_interface_demo;

import java.util.ArrayList;

// 实现接口，定义实现类，代表方案1
public class StudentOperatorimpl1 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("----------全班所有学生的信息如下----------");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名：" + s.getName() + "性别：" + s.getSex() + "成绩：" + s.getScore());
        }
        System.out.println("------------------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double allScore = 0.0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScore += s.getScore();
        }
        System.out.println("全班平均成绩为：" + allScore / students.size());
    }
}
